if(! require("spgwr") ) {
install.packages("spgwr")
library(spgwr)
}
aucun package nomm攼㸹 㤼㸱spgwr㤼㸲 n'est trouv攼㸹trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.4/spgwr_0.6-31.zip'
Content type 'application/zip' length 1884700 bytes (1.8 MB)
downloaded 1.8 MB
package ‘spgwr’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\jdeni\AppData\Local\Temp\Rtmp8wJL19\downloaded_packages
data(afcon)
oid <- order(afcon$id)
gg.totcon <- ggplot(afcon.extra) + aes(x=x, y=y, color=totcon, label=name) + geom_point() + geom_lab(mapping=aes(color="black")) + coord_fixed() + scale_color_distiller(palette="YlOrRd", direction = 1) + theme_minimal()
Error in geom_lab(mapping = aes(color = "black")) :
could not find function "geom_lab"
ggplotly(gg.totcon)
We recommend that you use the dev version of ggplot2 with `ggplotly()`
Install it with: `devtools::install_github('hadley/ggplot2')`
nb2df <- function(nb, coords){
x <- coords[, 1]
y <- coords[, 2]
n <- length(nb)
cardnb <- card(nb)
i <- rep(1:n, cardnb)
j <- unlist(nb)
return(data.frame(x=x[i], xend=x[j],
y=y[i], yend=y[j]))
}
af.nb.df <- nb2df(paper.nb, afxy)
resI <- localmoran(afcon$totcon, nb2listw(paper.nb))
printCoefmat(data.frame(resI[oid,], row.names=afcon$name[oid]),
check.names=FALSE, p.adjust.method="bonferroni")
Ii E.Ii Var.Ii Z.Ii Pr.z...0.
THE GAMBIA 0.3752254 -0.0243902 0.8707799 0.4282410 0.3342
MALI 0.4636340 -0.0243902 0.1084938 1.4816272 0.0692
SENEGAL 0.2567014 -0.0243902 0.2037796 0.6226838 0.2667
BENIN 0.1941194 -0.0243902 0.2037796 0.4840501 0.3142
MAURITANIA 0.0970535 -0.0243902 0.2037796 0.2690263 0.3940
NIGER 0.2307143 -0.0243902 0.1084938 0.7744898 0.2193
IVORY COAST 0.2900359 -0.0243902 0.1593129 0.7877586 0.2154
GUINEA 0.1826275 -0.0243902 0.1593129 0.5186592 0.3020
BURKINA FASO 0.5082778 -0.0243902 0.1296684 1.4792430 0.0695
LIBERIA 0.1856475 -0.0243902 0.2778907 0.3984375 0.3452
SIERRA LEONE 0.2652337 -0.0243902 0.4261130 0.4436823 0.3286
GHANA 0.1476406 -0.0243902 0.2778907 0.3263392 0.3721
TOGO 0.2193448 -0.0243902 0.2778907 0.4623607 0.3219
CAMEROON 0.2592454 -0.0243902 0.1593129 0.7106167 0.2387
NIGERIA 0.1137709 -0.0243902 0.2037796 0.3060593 0.3798
GABON 0.2036649 -0.0243902 0.4261130 0.3493635 0.3634
CENTRAL AFRICAN REPUBLIC -0.4420567 -0.0243902 0.1593129 -1.0464153 0.8523
CHAD -0.1052846 -0.0243902 0.1296684 -0.2246472 0.5889
CONGO 0.0113803 -0.0243902 0.2037796 0.0792401 0.4684
ZAIRE 0.7097807 -0.0243902 0.0802610 2.5914625 0.0048
ANGOLA 0.1179749 -0.0243902 0.2778907 0.2700640 0.3936
UGANDA 1.9425080 -0.0243902 0.1593129 4.9278382 0.0000
KENYA 1.1969287 -0.0243902 0.1593129 3.0598747 0.0011
TANZANIA 0.2718545 -0.0243902 0.0926129 0.9734529 0.1652
BURUNDI -0.4842787 -0.0243902 0.2778907 -0.8723997 0.8085
RWANDA -0.7523578 -0.0243902 0.2037796 -1.6126187 0.9466
SOMALIA 0.4527658 -0.0243902 0.4261130 0.7309674 0.2324
ETHIOPIA 0.7251240 -0.0243902 0.2778907 1.4218143 0.0775
ZAMBIA 0.0421598 -0.0243902 0.0926129 0.2186818 0.4134
ZIMBABWE -0.0095068 -0.0243902 0.2037796 0.0329703 0.4868
MALAWI -0.2288840 -0.0243902 0.2778907 -0.3879207 0.6510
MOZAMBIQUE 0.0167900 -0.0243902 0.1296684 0.1143594 0.4545
SOUTH AFRICA -0.1825396 -0.0243902 0.1084938 -0.4801368 0.6844
LESOTHO -0.4193478 -0.0243902 0.8707799 -0.4232493 0.6639
BOTSWANA -0.0039316 -0.0243902 0.2778907 0.0388096 0.4845
SWAZILAND 0.0166842 -0.0243902 0.4261130 0.0629231 0.4749
MOROCCO -0.0969607 -0.0243902 0.4261130 -0.1111725 0.5443
ALGERIA -0.0100369 -0.0243902 0.1296684 0.0398599 0.4841
TUNISIA 0.0053873 -0.0243902 0.4261130 0.0456170 0.4818
LIBYA 0.8038237 -0.0243902 0.1296684 2.2999872 0.0107
SUDAN 2.9877738 -0.0243902 0.0926129 9.8978982 0.0000
EGYPT 6.9467291 -0.0243902 0.4261130 10.6792343 0.0000
gg.localI <- ggplot(afcon.extra) + aes(x=x, y=y, color=localIlevel) +
geom_point(aes(text=paste(name, localI), size=2)) + scale_color_brewer(palette="RdYlBu", direction = -1) +
geom_segment(data = af.nb.df, aes(x=x, xend=xend, y=y, yend=yend), color="grey") + coord_fixed() + theme_minimal()
Ignoring unknown aesthetics: text
ggplotly(gg.localI)
We recommend that you use the dev version of ggplot2 with `ggplotly()`
Install it with: `devtools::install_github('hadley/ggplot2')`
afcon.extra$localG <- as.numeric(localG(afcon$totcon, nb2listw(paper.nb))[,1])
Error in localG(afcon$totcon, nb2listw(paper.nb))[, 1] :
incorrect number of dimensions
gg.localG <- ggplot(afcon.extra) + aes(x=x, y=y, color=scale(localG, center = TRUE, scale = TRUE)) +
geom_point(aes(text=paste(name, "localG", localG), size=2)) + scale_color_distiller(palette="OrRd", direction = 1) +
geom_segment(data = af.nb.df, aes(x=x, xend=xend, y=y, yend=yend), color="grey") + coord_fixed() + theme_minimal()
Ignoring unknown aesthetics: text
ggplotly(gg.localG)
We recommend that you use the dev version of ggplot2 with `ggplotly()`
Install it with: `devtools::install_github('hadley/ggplot2')`
afcon.extra$lag.totcon <- lag.listw(nb2listw(paper.nb),afcon$totcon )
Error in lag.listw(nb2listw(paper.nb), afcon$totcon) :
could not find function "lag.listw"
gg.lag <- ggplot(afcon.extra) + aes(x=x, y=y, color=lag.totcon) +
geom_point(aes(text=paste(name, "totcon:", totcon, "totcon décallé:", lag.totcon), size=2)) + scale_color_distiller(palette="OrRd", direction = 1) +
geom_segment(data = af.nb.df, aes(x=x, xend=xend, y=y, yend=yend), color="grey") + coord_fixed() + theme_minimal()
Ignoring unknown aesthetics: text
ggplotly(gg.lag)
We recommend that you use the dev version of ggplot2 with `ggplotly()`
Install it with: `devtools::install_github('hadley/ggplot2')`
```